<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名称</td>
                    <td><input type="text" v-model="data.LogName"></td>
                </tr>
                <tr>
                    <td>用户密码</td>
                    <td><input type="password" v-model="data.LogPass"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="Deng"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const data = ref({
    "LogId": 0,
  "LogName": "",
  "LogPass": ""
})
const router = useRouter()
const Deng = ()=>{
    axios.get('https://localhost:7087/api/Login/Deng',{params:data.value}).then(res=>{
        if(res.data.LogId==-1){
            alert('用户不存在');
        }
        else{
            if(res.data.LogId==-2){
                alert('登录失败，密码错误');
                return
            }
            else{
                alert('登陆成功')
                router.push({path:"/BingShow"})
            }
        }
    })
}



</script>

<style scoped>

</style>